//
//  Author: Tushar Jog
//  Timestamp: <testStream.cpp Sun 2009/08/02 12:19:11 tjog>
//

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
// #include <boost/iostreams/filtering_streambuf.hpp>
// #include <boost/iostreams/copy.hpp>
// #include <boost/iostreams/filter/gzip.hpp>

#include <cassert>

// #include "stdf.h"
#include "records.h"
#include "stream.h"

using namespace std;
using namespace stdf;

int main(int argc, char** argv) {
    if(argc <= 1)
        return 1;

    Stream istdf;

    string filename;
    filename = argv[1];

    bool result = istdf.open( filename, ReadOnly);
    cout << "File open : " << result << endl;

#if 0
    for(unsigned int i=0; i < 20; i++) {
        U1 temp = '_';
        istdf >> temp;
        cout << (int) temp << endl;
    }
#endif

    string sep = "\t";
    RecordHeader header(0,0,0);
    istdf >> header;
    //cout << header.length << sep << header.type << sep << header.subType << endl;
    cout << header << endl;
    //cout << header.getRecordType() << endl;

    //assert(header.getRecordType() == FAR);
    FARRecord far(0,0);
    istdf >> far;

    istdf.setByteOrder( far.getByteOrder());

    //cout << far.getLength()    << endl;
    //cout << far.getByteOrder() << endl;
    //cout << far.getCpuType()   << endl;
    cout << far << endl;

    istdf >> header;
    cout << header << endl;

    if(header.getRecordType() == MIR) {
        MIRRecord mir;
        istdf >> mir;
        cout << mir << endl;

    }
}


